/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * JFrame_ChiTietMail.java
 *
 * Created on May 28, 2009, 7:55:46 AM
 */

package doanlythuyet_javaoutlook.MyUserControl;

import BUS.MyAttachBUS;
import BUS.MyMailBUS;
import DTO.MyAttachDTO;
import DTO.MyMailDTO;
import doanlythuyet_javaoutlook.DoAnLyThuyet_JavaOutLookApp;
import doanlythuyet_javaoutlook.EventListener_ClickChuotVaoCayDuyetFile;
import doanlythuyet_javaoutlook.MyMail;
import java.awt.Desktop;
import java.awt.event.MouseEvent;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.mail.Part;
import javax.mail.internet.MimeMessage;
import javax.swing.DefaultListModel;
import javax.swing.JOptionPane;
import javax.swing.ListModel;

/**
 *
 * @author Dang Thi Phuong Thao
 */
public class JFrame_ChiTietMail extends javax.swing.JFrame {


    private int m_MailID;
    /** Creates new form JFrame_ChiTietMail */
    public JFrame_ChiTietMail() {
        initComponents();
    }

    public JFrame_ChiTietMail (int MailId){
            m_MailID = MailId;
            initComponents();
            //jEditorPane_noidung.setText("Doc va load noi dung mail: " + MailID + " (JFrame_ChiTietMail.java dong 27)");
            FileInputStream inputStream = null;
        try {
            MyMailDTO mailDTO = new MyMailBUS().layMailVoidMailID(String.valueOf(MailId));
            jLabel_chude.setText(mailDTO.getM_ChuDe());
            jLabel_goi.setText(mailDTO.getM_NguoiGoi());
            jLabel_den.setText(mailDTO.getM_NguoiNhan());
            jLabel_ngay.setText(mailDTO.getM_Ngay().toString());
            inputStream = new FileInputStream(new File(DoAnLyThuyet_JavaOutLookApp.getCurdir() + mailDTO.getM_DuongDanFileChuaNoiDung()));

            MyMail mail = new MyMail(DoAnLyThuyet_JavaOutLookApp.getSmtp_host(), DoAnLyThuyet_JavaOutLookApp.getPop3_host(), DoAnLyThuyet_JavaOutLookApp.getUser()
                , DoAnLyThuyet_JavaOutLookApp.getPass(), DoAnLyThuyet_JavaOutLookApp.getProxy(), DoAnLyThuyet_JavaOutLookApp.getPort());MimeMessage mess = new MimeMessage(mail.getMailSession(false), inputStream);
            Part textPart = MyMail.layPartNoiDung(mess);
            if (textPart != null){
                jEditorPane_noidung.setContentType(textPart.getContentType());
                jEditorPane_noidung.setText(textPart.getContent().toString());
            }
            DefaultListModel listModel = new DefaultListModel();
            listModel.clear();
            ArrayList<MyAttachDTO> attachDTOs = new MyAttachBUS().layTatCaAttachCuaMailID(MailId);
            for (MyAttachDTO part : attachDTOs){
                listModel.addElement(part.getM_TenFile() + ">" + DoAnLyThuyet_JavaOutLookApp.getCurdir() + part.getM_DuongDan());
            }
            jList1.setModel(listModel);

        } catch (Exception ex) {
            Logger.getLogger(JPanel_XemMail.class.getName()).log(Level.SEVERE, null, ex);
            JOptionPane.showMessageDialog(null, ex.toString());
        }
        try {
            inputStream.close();
        } catch (IOException ex) {
            Logger.getLogger(JPanel_XemMail.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jToolBar1 = new javax.swing.JToolBar();
        jScrollPane1 = new javax.swing.JScrollPane();
        jToolBar2 = new javax.swing.JToolBar();
        jButton_Reply = new javax.swing.JButton();
        jButton_ReplyAll = new javax.swing.JButton();
        jButton1 = new javax.swing.JButton();
        jButton_Delete = new javax.swing.JButton();
        jScrollPane_noidung = new javax.swing.JScrollPane();
        jEditorPane_noidung = new javax.swing.JEditorPane();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel_chude = new javax.swing.JLabel();
        jLabel_goi = new javax.swing.JLabel();
        jLabel_ngay = new javax.swing.JLabel();
        jLabel_den = new javax.swing.JLabel();
        jLabel_cc = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        jList1 = new javax.swing.JList();
        menuBar = new javax.swing.JMenuBar();
        javax.swing.JMenu fileMenu = new javax.swing.JMenu();
        jMenu_New = new javax.swing.JMenu();
        jMenuItem_Mail = new javax.swing.JMenuItem();
        jMenuItem_Contact = new javax.swing.JMenuItem();
        jMenuItem_Task = new javax.swing.JMenuItem();
        jMenuItem_Folder = new javax.swing.JMenuItem();
        jSeparator1 = new javax.swing.JSeparator();
        jMenuItem_Save = new javax.swing.JMenuItem();
        jMenuItem_SaveAs = new javax.swing.JMenuItem();
        jMenuItem2 = new javax.swing.JMenuItem();
        jSeparator5 = new javax.swing.JSeparator();
        jMenuItem_delete = new javax.swing.JMenuItem();
        jMenuItem3 = new javax.swing.JMenuItem();
        jSeparator2 = new javax.swing.JSeparator();
        javax.swing.JMenuItem jMenuItem_Close = new javax.swing.JMenuItem();
        jMenu_Edit = new javax.swing.JMenu();
        jMenuItem_Cut = new javax.swing.JMenuItem();
        jMenuItem_Copy = new javax.swing.JMenuItem();
        jMenuItem_Paste = new javax.swing.JMenuItem();
        jSeparator3 = new javax.swing.JSeparator();
        jMenuItem_SelectAll = new javax.swing.JMenuItem();
        jSeparator4 = new javax.swing.JSeparator();
        jMenuItem1 = new javax.swing.JMenuItem();
        jMenu_Tools = new javax.swing.JMenu();
        jMenuItem_Find = new javax.swing.JMenuItem();
        javax.swing.JMenu helpMenu = new javax.swing.JMenu();
        javax.swing.JMenuItem aboutMenuItem = new javax.swing.JMenuItem();

        jToolBar1.setRollover(true);
        jToolBar1.setName("jToolBar1"); // NOI18N

        jScrollPane1.setName("jScrollPane1"); // NOI18N

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setName("Form"); // NOI18N

        jToolBar2.setRollover(true);
        jToolBar2.setName("jToolBar2"); // NOI18N

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(doanlythuyet_javaoutlook.DoAnLyThuyet_JavaOutLookApp.class).getContext().getResourceMap(JFrame_ChiTietMail.class);
        jButton_Reply.setIcon(resourceMap.getIcon("jButton_Reply.icon")); // NOI18N
        jButton_Reply.setText(resourceMap.getString("jButton_Reply.text")); // NOI18N
        jButton_Reply.setFocusable(false);
        jButton_Reply.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton_Reply.setName("jButton_Reply"); // NOI18N
        jButton_Reply.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jToolBar2.add(jButton_Reply);

        jButton_ReplyAll.setIcon(resourceMap.getIcon("jButton_ReplyAll.icon")); // NOI18N
        jButton_ReplyAll.setText(resourceMap.getString("jButton_ReplyAll.text")); // NOI18N
        jButton_ReplyAll.setFocusable(false);
        jButton_ReplyAll.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton_ReplyAll.setName("jButton_ReplyAll"); // NOI18N
        jButton_ReplyAll.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jToolBar2.add(jButton_ReplyAll);

        jButton1.setIcon(resourceMap.getIcon("jButton1.icon")); // NOI18N
        jButton1.setText(resourceMap.getString("jButton1.text")); // NOI18N
        jButton1.setFocusable(false);
        jButton1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton1.setName("jButton1"); // NOI18N
        jButton1.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jToolBar2.add(jButton1);

        jButton_Delete.setIcon(resourceMap.getIcon("jButton_Delete.icon")); // NOI18N
        jButton_Delete.setText(resourceMap.getString("jButton_Delete.text")); // NOI18N
        jButton_Delete.setFocusable(false);
        jButton_Delete.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton_Delete.setName("jButton_Delete"); // NOI18N
        jButton_Delete.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jToolBar2.add(jButton_Delete);

        jScrollPane_noidung.setName("jScrollPane_noidung"); // NOI18N

        jEditorPane_noidung.setEditable(false);
        jEditorPane_noidung.setName("jEditorPane_noidung"); // NOI18N
        jScrollPane_noidung.setViewportView(jEditorPane_noidung);
        jEditorPane_noidung.getAccessibleContext().setAccessibleDescription(resourceMap.getString("jEditorPane1.AccessibleContext.accessibleDescription")); // NOI18N

        jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N

        jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
        jLabel2.setName("jLabel2"); // NOI18N

        jLabel3.setText(resourceMap.getString("jLabel3.text")); // NOI18N
        jLabel3.setName("jLabel3"); // NOI18N

        jLabel4.setText(resourceMap.getString("jLabel4.text")); // NOI18N
        jLabel4.setName("jLabel4"); // NOI18N

        jLabel5.setText(resourceMap.getString("jLabel5.text")); // NOI18N
        jLabel5.setName("jLabel5"); // NOI18N

        jLabel_chude.setFont(resourceMap.getFont("jLabel_chude.font")); // NOI18N
        jLabel_chude.setForeground(resourceMap.getColor("jLabel_chude.foreground")); // NOI18N
        jLabel_chude.setText(resourceMap.getString("jLabel_chude.text")); // NOI18N
        jLabel_chude.setName("jLabel_chude"); // NOI18N

        jLabel_goi.setFont(resourceMap.getFont("jLabel_goi.font")); // NOI18N
        jLabel_goi.setForeground(resourceMap.getColor("jLabel_goi.foreground")); // NOI18N
        jLabel_goi.setText(resourceMap.getString("jLabel_goi.text")); // NOI18N
        jLabel_goi.setName("jLabel_goi"); // NOI18N

        jLabel_ngay.setFont(resourceMap.getFont("jLabel_ngay.font")); // NOI18N
        jLabel_ngay.setForeground(resourceMap.getColor("jLabel_ngay.foreground")); // NOI18N
        jLabel_ngay.setText(resourceMap.getString("jLabel_ngay.text")); // NOI18N
        jLabel_ngay.setName("jLabel_ngay"); // NOI18N

        jLabel_den.setFont(resourceMap.getFont("jLabel_den.font")); // NOI18N
        jLabel_den.setForeground(resourceMap.getColor("jLabel_den.foreground")); // NOI18N
        jLabel_den.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        jLabel_den.setText(resourceMap.getString("jLabel_den.text")); // NOI18N
        jLabel_den.setName("jLabel_den"); // NOI18N

        jLabel_cc.setFont(resourceMap.getFont("jLabel_cc.font")); // NOI18N
        jLabel_cc.setForeground(resourceMap.getColor("jLabel_cc.foreground")); // NOI18N
        jLabel_cc.setText(resourceMap.getString("jLabel_cc.text")); // NOI18N
        jLabel_cc.setName("jLabel_cc"); // NOI18N

        jScrollPane2.setName("jScrollPane2"); // NOI18N

        jList1.setBorder(javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("jList1.border.title"))); // NOI18N
        jList1.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        jList1.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_INTERVAL_SELECTION);
        jList1.setName("jList1"); // NOI18N
        jList1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jList1MouseClicked(evt);
            }
        });
        jScrollPane2.setViewportView(jList1);

        menuBar.setName("menuBar"); // NOI18N

        fileMenu.setText(resourceMap.getString("fileMenu.text")); // NOI18N
        fileMenu.setName("fileMenu"); // NOI18N

        jMenu_New.setText(resourceMap.getString("jMenu_New.text")); // NOI18N
        jMenu_New.setName("jMenu_New"); // NOI18N

        jMenuItem_Mail.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_N, java.awt.event.InputEvent.CTRL_MASK));
        jMenuItem_Mail.setText(resourceMap.getString("jMenuItem_Mail.text")); // NOI18N
        jMenuItem_Mail.setName("jMenuItem_Mail"); // NOI18N
        jMenu_New.add(jMenuItem_Mail);

        jMenuItem_Contact.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C, java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
        jMenuItem_Contact.setText(resourceMap.getString("jMenuItem_Contact.text")); // NOI18N
        jMenuItem_Contact.setName("jMenuItem_Contact"); // NOI18N
        jMenu_New.add(jMenuItem_Contact);

        jMenuItem_Task.setText(resourceMap.getString("jMenuItem_Task.text")); // NOI18N
        jMenuItem_Task.setName("jMenuItem_Task"); // NOI18N
        jMenu_New.add(jMenuItem_Task);

        jMenuItem_Folder.setText(resourceMap.getString("jMenuItem_Folder.text")); // NOI18N
        jMenuItem_Folder.setName("jMenuItem_Folder"); // NOI18N
        jMenu_New.add(jMenuItem_Folder);

        fileMenu.add(jMenu_New);

        jSeparator1.setName("jSeparator1"); // NOI18N
        fileMenu.add(jSeparator1);

        jMenuItem_Save.setText(resourceMap.getString("jMenuItem_Save.text")); // NOI18N
        jMenuItem_Save.setName("jMenuItem_Save"); // NOI18N
        fileMenu.add(jMenuItem_Save);

        jMenuItem_SaveAs.setText(resourceMap.getString("jMenuItem_SaveAs.text")); // NOI18N
        jMenuItem_SaveAs.setName("jMenuItem_SaveAs"); // NOI18N
        fileMenu.add(jMenuItem_SaveAs);

        jMenuItem2.setText(resourceMap.getString("jMenuItem2.text")); // NOI18N
        jMenuItem2.setName("jMenuItem2"); // NOI18N
        fileMenu.add(jMenuItem2);

        jSeparator5.setName("jSeparator5"); // NOI18N
        fileMenu.add(jSeparator5);

        jMenuItem_delete.setText(resourceMap.getString("jMenuItem_delete.text")); // NOI18N
        jMenuItem_delete.setName("jMenuItem_delete"); // NOI18N
        fileMenu.add(jMenuItem_delete);

        jMenuItem3.setText(resourceMap.getString("jMenuItem3.text")); // NOI18N
        jMenuItem3.setName("jMenuItem3"); // NOI18N
        fileMenu.add(jMenuItem3);

        jSeparator2.setName("jSeparator2"); // NOI18N
        fileMenu.add(jSeparator2);

        javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance(doanlythuyet_javaoutlook.DoAnLyThuyet_JavaOutLookApp.class).getContext().getActionMap(JFrame_ChiTietMail.class, this);
        jMenuItem_Close.setAction(actionMap.get("quit")); // NOI18N
        jMenuItem_Close.setText(resourceMap.getString("jMenuItem_Close.text")); // NOI18N
        jMenuItem_Close.setName("jMenuItem_Close"); // NOI18N
        fileMenu.add(jMenuItem_Close);

        menuBar.add(fileMenu);

        jMenu_Edit.setText(resourceMap.getString("jMenu_Edit.text")); // NOI18N
        jMenu_Edit.setName("jMenu_Edit"); // NOI18N

        jMenuItem_Cut.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_X, java.awt.event.InputEvent.CTRL_MASK));
        jMenuItem_Cut.setText(resourceMap.getString("jMenuItem_Cut.text")); // NOI18N
        jMenuItem_Cut.setName("jMenuItem_Cut"); // NOI18N
        jMenu_Edit.add(jMenuItem_Cut);

        jMenuItem_Copy.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C, java.awt.event.InputEvent.CTRL_MASK));
        jMenuItem_Copy.setText(resourceMap.getString("jMenuItem_Copy.text")); // NOI18N
        jMenuItem_Copy.setName("jMenuItem_Copy"); // NOI18N
        jMenu_Edit.add(jMenuItem_Copy);

        jMenuItem_Paste.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_V, java.awt.event.InputEvent.CTRL_MASK));
        jMenuItem_Paste.setText(resourceMap.getString("jMenuItem_Paste.text")); // NOI18N
        jMenuItem_Paste.setName("jMenuItem_Paste"); // NOI18N
        jMenu_Edit.add(jMenuItem_Paste);

        jSeparator3.setName("jSeparator3"); // NOI18N
        jMenu_Edit.add(jSeparator3);

        jMenuItem_SelectAll.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_A, java.awt.event.InputEvent.CTRL_MASK));
        jMenuItem_SelectAll.setText(resourceMap.getString("jMenuItem_SelectAll.text")); // NOI18N
        jMenuItem_SelectAll.setName("jMenuItem_SelectAll"); // NOI18N
        jMenu_Edit.add(jMenuItem_SelectAll);

        jSeparator4.setName("jSeparator4"); // NOI18N
        jMenu_Edit.add(jSeparator4);

        jMenuItem1.setText(resourceMap.getString("jMenuItem1.text")); // NOI18N
        jMenuItem1.setName("jMenuItem1"); // NOI18N
        jMenu_Edit.add(jMenuItem1);

        menuBar.add(jMenu_Edit);

        jMenu_Tools.setText(resourceMap.getString("jMenu_Tools.text")); // NOI18N
        jMenu_Tools.setName("jMenu_Tools"); // NOI18N

        jMenuItem_Find.setText(resourceMap.getString("jMenuItem_Find.text")); // NOI18N
        jMenuItem_Find.setName("jMenuItem_Find"); // NOI18N
        jMenu_Tools.add(jMenuItem_Find);

        menuBar.add(jMenu_Tools);

        helpMenu.setText(resourceMap.getString("helpMenu.text")); // NOI18N
        helpMenu.setName("helpMenu"); // NOI18N

        aboutMenuItem.setAction(actionMap.get("showAboutBox")); // NOI18N
        aboutMenuItem.setName("aboutMenuItem"); // NOI18N
        helpMenu.add(aboutMenuItem);

        menuBar.add(helpMenu);

        setJMenuBar(menuBar);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(26, 26, 26)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel2)
                            .addComponent(jLabel1)
                            .addComponent(jLabel3)
                            .addComponent(jLabel4)
                            .addComponent(jLabel5))
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel_den, javax.swing.GroupLayout.PREFERRED_SIZE, 236, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel_ngay, javax.swing.GroupLayout.PREFERRED_SIZE, 236, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel_goi, javax.swing.GroupLayout.PREFERRED_SIZE, 236, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel_chude, javax.swing.GroupLayout.PREFERRED_SIZE, 236, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel_cc, javax.swing.GroupLayout.PREFERRED_SIZE, 236, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 103, Short.MAX_VALUE)
                        .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 241, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jToolBar2, javax.swing.GroupLayout.DEFAULT_SIZE, 614, Short.MAX_VALUE)
                                .addGap(38, 38, 38))
                            .addComponent(jScrollPane_noidung))))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jToolBar2, javax.swing.GroupLayout.PREFERRED_SIZE, 49, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel1)
                            .addComponent(jLabel_chude))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel2)
                            .addComponent(jLabel_goi))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel3)
                            .addComponent(jLabel_ngay))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel4)
                            .addComponent(jLabel_den))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel5)
                            .addComponent(jLabel_cc)))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(4, 4, 4)
                        .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 127, Short.MAX_VALUE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane_noidung, javax.swing.GroupLayout.PREFERRED_SIZE, 312, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jList1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jList1MouseClicked
        // TODO add your handling code here:
        if (evt.getButton() == MouseEvent.BUTTON1 && evt.getClickCount() ==2){
            try {
                Object sel = jList1.getSelectedValue();
                if (sel != null) {
                    Desktop.getDesktop().open(new File(sel.toString().split(">")[1]));
                }
            } catch (IOException ex) {
                Logger.getLogger(JFrame_ChiTietMail.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }//GEN-LAST:event_jList1MouseClicked

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new JFrame_ChiTietMail().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton_Delete;
    private javax.swing.JButton jButton_Reply;
    private javax.swing.JButton jButton_ReplyAll;
    private javax.swing.JEditorPane jEditorPane_noidung;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel_cc;
    private javax.swing.JLabel jLabel_chude;
    private javax.swing.JLabel jLabel_den;
    private javax.swing.JLabel jLabel_goi;
    private javax.swing.JLabel jLabel_ngay;
    private javax.swing.JList jList1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JMenuItem jMenuItem3;
    private javax.swing.JMenuItem jMenuItem_Contact;
    private javax.swing.JMenuItem jMenuItem_Copy;
    private javax.swing.JMenuItem jMenuItem_Cut;
    private javax.swing.JMenuItem jMenuItem_Find;
    private javax.swing.JMenuItem jMenuItem_Folder;
    private javax.swing.JMenuItem jMenuItem_Mail;
    private javax.swing.JMenuItem jMenuItem_Paste;
    private javax.swing.JMenuItem jMenuItem_Save;
    private javax.swing.JMenuItem jMenuItem_SaveAs;
    private javax.swing.JMenuItem jMenuItem_SelectAll;
    private javax.swing.JMenuItem jMenuItem_Task;
    private javax.swing.JMenuItem jMenuItem_delete;
    private javax.swing.JMenu jMenu_Edit;
    private javax.swing.JMenu jMenu_New;
    private javax.swing.JMenu jMenu_Tools;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane_noidung;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JSeparator jSeparator3;
    private javax.swing.JSeparator jSeparator4;
    private javax.swing.JSeparator jSeparator5;
    private javax.swing.JToolBar jToolBar1;
    private javax.swing.JToolBar jToolBar2;
    private javax.swing.JMenuBar menuBar;
    // End of variables declaration//GEN-END:variables

    /**
     * @return the m_MailID
     */
    public int getMailID() {
        return m_MailID;
    }

    /**
     * @param m_MailID the m_MailID to set
     */
    public void setMailID(int mailID) {
        this.m_MailID = mailID;
    }

    //<editor-fold defaultstate="collapsed" desc="Dung de phat sinh su kien">
    //Các hàm sau phục vụ cho việc gởi sự kiện click chuột vào bảng ra ngoài (tham khảo từ nhiều nguồn trên mạng)
    //http://www.exampledepot.com/egs/java.util/CustEvent.html
    // Tạo một listener list
    protected javax.swing.event.EventListenerList listenerList =
            new javax.swing.event.EventListenerList();

    /**
     * Phát sinh sử kiện click chuột vào tree
     * @param evt tham số cho sự kiện click chuột vào tree (ở đây là tên của file đang được chọn)
     */
    // This private class is used to fire MyEvents
    void initEvent_ClickChuotVaoCayDuyetFile(String evt) {
        Object[] listeners = listenerList.getListenerList();
        // Each listener occupies two elements - the first is the listener class
        // and the second is the listener instance
        for (int i = 0; i < listeners.length; i += 2) {
            if (listeners[i] == EventListener_ClickChuotVaoCayDuyetFile.class) {
                ((EventListener_ClickChuotVaoCayDuyetFile) listeners[i + 1]).Event_ClickChuotVaoCayDuyetFile_Occurred(evt);
            }
        }
    }

    /**
     * Đăng ký sự kiện cho classes
     * @param listener  Sự kiện cần đăng ký
     */
    public void addEventListener_ClickChuotVaoCayDuyetFile(EventListener_ClickChuotVaoCayDuyetFile listener) {
        listenerList.add(EventListener_ClickChuotVaoCayDuyetFile.class, listener);
    }

    /**
     * Gỡ bỏ sự kiện khỏi classes
     * @param listener  Sự kiện cần gỡ bỏ
     */
    public void delEventListener_ClickChuotVaoCayDuyetFile(EventListener_ClickChuotVaoCayDuyetFile listener) {
        listenerList.remove(EventListener_ClickChuotVaoCayDuyetFile.class, listener);
    }
    //</editor-fold>
}
